<?php

class ActivityBean implements IDBBean {
	
	public $id;
	public $activityType;
	public $type;
	public $department;
	public $name;
	public $host;
	public $activityBegin;
	public $activityEnd;
	public $location;
	public $content;
	public $budget;
	public $time;
	public $new = true;
	public $approval = false;
	public $applicant;
	
	public static $SEMINAR = 0;
	public static $EXCLUSIVE = 1;
	public static $TEACHER_COM = 2;
	public static $TEACHER_TRAIN = 3;
	public static $INSTITUTE_SEM = 4;
	public static $MENTOR_LUNCH = 5;
	public static $SUBJECT_COM = 6;
	public static $UNIVERSITY_COM = 7;
	public static $INTERNATIONAL_COM = 8;
	
	public $activityTypeLabels = array ("研讨会", "共同体专属活动", "教师交流", "教师培训", "院系研讨", "导师午餐会", "学科间交流", "校际交流", "国际交流" );
	
	public function __construct($fields = array()) {
		foreach ( $fields as $key => $value ) {
			if(property_exists("ActivityBean", $key))
				$this->$key = $value;
		}
	}
	
	/**
	 * Declares attribute labels.
	 */
	// 	public function attributeLabels() {
	// 		return array ('activityType' => '活动类型', 'type' => '子类型', 'department' => '主办院系', 'name' => '活动名称', 'host' => '主持人/主讲人', 'activityBegin' => '开始时间', 'activityEnd' => '结束时间', 'location' => '地点', 'content' => '内容简介', 'budget' => '经费预算', 'time' => '时长', 'applicant' => '活动申请人' );
	// 	}
	

	/**
	 * @return the $id
	 */
	public function getId() {
		return $this->id;
	}
	
	/**
	 * @return the $time
	 */
	public function getTime() {
		return $this->time;
	}
	
	/**
	 * @return the $new
	 */
	public function getNew() {
		return $this->new;
	}
	
	/**
	 * @return the $approval
	 */
	public function getApproval() {
		return $this->approval;
	}
	
	/**
	 * @return the $applicant
	 */
	public function getApplicant() {
		return $this->applicant;
	}
	
	/**
	 * @param field_type $id
	 */
	public function setId($id) {
		$this->id = $id;
	}
	
	/**
	 * @param field_type $time
	 */
	public function setTime($time) {
		$this->time = $time;
	}
	
	/**
	 * @param field_type $new
	 */
	public function setNew($new) {
		$this->new = $new;
	}
	
	/**
	 * @param field_type $approval
	 */
	public function setApproval($approval) {
		$this->approval = $approval;
	}
	
	/**
	 * @param field_type $applicant
	 */
	public function setApplicant($applicant) {
		$this->applicant = $applicant;
	}
	
	/**
	 * @return the $activityType
	 */
	public function getActivityType() {
		return $this->activityType;
	}
	
	/**
	 * @return the $type
	 */
	public function getType() {
		return $this->type;
	}
	
	/**
	 * @return the $department
	 */
	public function getDepartment() {
		return $this->department;
	}
	
	/**
	 * @return the $name
	 */
	public function getName() {
		return $this->name;
	}
	
	/**
	 * @return the $host
	 */
	public function getHost() {
		return $this->host;
	}
	
	/**
	 * @return the $activityBegin
	 */
	public function getActivityBegin() {
		return $this->activityBegin;
	}
	
	/**
	 * @return the $activityEnd
	 */
	public function getActivityEnd() {
		return $this->activityEnd;
	}
	
	/**
	 * @return the $location
	 */
	public function getLocation() {
		return $this->location;
	}
	
	/**
	 * @return the $content
	 */
	public function getContent() {
		return $this->content;
	}
	
	/**
	 * @return the $budget
	 */
	public function getBudget() {
		return $this->budget;
	}
	
	/**
	 * @param field_type $activityType
	 */
	public function setActivityType($activityType) {
		$this->activityType = $activityType;
	}
	
	/**
	 * @param field_type $type
	 */
	public function setType($type) {
		$this->type = $type;
	}
	
	/**
	 * @param field_type $department
	 */
	public function setDepartment($department) {
		$this->department = $department;
	}
	
	/**
	 * @param field_type $name
	 */
	public function setName($name) {
		$this->name = $name;
	}
	
	/**
	 * @param field_type $host
	 */
	public function setHost($host) {
		$this->host = $host;
	}
	
	/**
	 * @param field_type $activityBegin
	 */
	public function setActivityBegin($activityBegin) {
		$this->activityBegin = $activityBegin;
	}
	
	/**
	 * @param field_type $activityEnd
	 */
	public function setActivityEnd($activityEnd) {
		$this->activityEnd = $activityEnd;
	}
	
	/**
	 * @param field_type $location
	 */
	public function setLocation($location) {
		$this->location = $location;
	}
	
	/**
	 * @param field_type $content
	 */
	public function setContent($content) {
		$this->content = $content;
	}
	
	/**
	 * @param field_type $budget
	 */
	public function setBudget($budget) {
		$this->budget = $budget;
	}
	
	public function getTypeLabel() {
		return $this->activityTypeLabels [$this->type];
	}
	
	public static function findById($id) {
		$sql = "select * from activity where id='$id'";
		$db = MysqliObj::getInstance ();
		$data = $db->fetch_array ( $sql );
		if (! $data) {
			$activity = null;
		} else {
			$activity = new ActivityBean ( $data );
		}
		return $activity;
	}
}
?>